guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggested fix in numbers.c


From: Roland Orre
Subject: Suggested fix in numbers.c
Date: 29 Dec 2002 00:25:58 +0100

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]