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: Suggested fix in numbers.c Date: 29 Dec 2002 00:25:58 +0100 Organization: Royal Institute of Technology Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <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 1041118002 24111 80.91.224.249 (28 Dec 2002 23:26:42 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 28 Dec 2002 23:26:42 +0000 (UTC) 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 18SQLp-0006Gl-00 for ; Sun, 29 Dec 2002 00:26:41 +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 18SQLi-0005NW-03 for guile-user@m.gmane.org; Sat, 28 Dec 2002 18:26:34 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18SQLL-0005NO-00 for guile-user@gnu.org; Sat, 28 Dec 2002 18:26:11 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18SQLJ-0005Lh-00 for guile-user@gnu.org; Sat, 28 Dec 2002 18:26:10 -0500 Original-Received: from smtp.nada.kth.se ([130.237.222.232]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18SQLJ-0005HX-00 for guile-user@gnu.org; Sat, 28 Dec 2002 18:26:09 -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 gBSNQ0Nd010061; Sun, 29 Dec 2002 00:26:06 +0100 (MET) Original-To: guile-user@gnu.org X-Mailer: Ximian Evolution 1.2.0 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:1476 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1476 Below is my standard fix to numbers.c since I started using guile 95. It allows for instance, which is my most common use, to let the user set the float format to the C format string "%g" etc, by setting the routine scm_user_idbl2str to a user specifed one. This to avoid excess in decimals, for instance when looking at single float vectors, where it's annoying to inspect a value and see e.g. #s(0.00519724749028683 0.00519724749028683 0.0 0.0 0.0 ... Of course, today, general float outputs can be nicely handled by specific formats strings in the output generation, which is also thread safe as different threads can have different desires, but for general purpose interaction and prototyping I find this fix to be very useful. Best regards Roland Orre in numbers.c #ifdef USER_FLOAT_FORMAT size_t scm_idbl2str (double f, char *a); size_t (*scm_user_idbl2str)(double f,char *a); #define idbl2str(f,a) scm_user_idbl2str(f,a) size_t scm_idbl2str (double f, char *a) #else static size_t idbl2str (double f, char *a) #endif and in the init routine to make the fix transparent when no user modules are loaded. void scm_init_numbers () { #ifdef USER_FLOAT_FORMAT scm_user_idbl2str=scm_idbl2str; #endif _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user